import service from '../utils/axios'

interface ApiResponse {
    code: number;
    data?: any;
    message?: string;
}

/**
 * 首页
 */
export const getClassrooms = (): Promise<ApiResponse> => {
    return service.get('screen/home/getClassrooms')
}
export const getThreeDimensionalModels = (): Promise<ApiResponse> => {
    return service.get('screen/home/getThreeDimensionalModels')
}
export const getLastDataAlarmList = (id: number): Promise<ApiResponse> => {
    return service.get(`screen/home/getLastDataAlarmList?id=${id}`)
}

/**
 * 化工工艺
 */
export const getTechnologyDevices = (id: number | string): Promise<ApiResponse> => {
    return service.get(`screen/technology/getTechnologyDevices?id=${id}`)
}
export const getTechnologyDeviceParamList = (id: number, pageNum: number, pageSize: number): Promise<ApiResponse> => {
    return service.get(`screen/technology/getTechnologyDeviceParamList?id=${id}&pageNum=${pageNum}&pageSize=${pageSize}`)
}
export const getDataAlarmTechnologyList = (id: number): Promise<ApiResponse> => {
    return service.get(`screen/technology/getDataAlarmTechnologyList?id=${id}&pageNum=1&pageSize=100`)
}
// 监控设备
export const getTechnologyDeviceMonitors = (id: number | string): Promise<ApiResponse> => {
    return service.get(`screen/technology/getTechnologyDeviceMonitors?id=${id}`)
}
export const getTechnologyDeviceLineChart = (id: number | string): Promise<ApiResponse> => {
    return service.get(`screen/technology/getTechnologyDeviceLineChart?id=${id}`)
}

export const getTechnologyDeviceLabels = (id: number | string): Promise<ApiResponse> => {
    return service.get(`screen/technology/getTechnologyDeviceLabels?id=${id}`)
}

/**
 * AI行为分析
 */
// 试试告警
export const getBehaviorList = (): Promise<ApiResponse> => {
    return service.get(`screen/ai/getBehaviorList`)
}
export const getCountByAlertTypeList = (): Promise<ApiResponse> => {
    return service.get(`screen/ai/getCountByAlertTypeList`)
}
export const getCountByDayList = (): Promise<ApiResponse> => {
    return service.get(`screen/ai/getCountByDayList`)
}
export const getVideoUrlList = (): Promise<ApiResponse> => {
    return service.get(`screen/ai/getVideoUrlList`)
}

/**
 * 用电安全
 */
// 设备信息下拉框
export const getDeviceInfos = (id: string): Promise<ApiResponse> => {
    return service.get(`screen/energyConsumption/getDeviceInfos?id=${id}`)
}
// 告警信息
export const getDataAlarmEnergyConsumptionList = (id: string): Promise<ApiResponse> => {
    return service.get(`screen/energyConsumption/getDataAlarmEnergyConsumptionList?id=${id}&pageNum=1&pageSize=100`)
}
// 顶部对比信息
export const getEnergyConsumptionCompareDatas = (id: number | string): Promise<ApiResponse> => {
    return service.get(`screen/energyConsumption/getEnergyConsumptionCompareDatas?id=${id}`)
}
// 能源流向
export const getEnergyConsumptionTotalData = (id: number | string): Promise<ApiResponse> => {
    return service.get(`screen/energyConsumption/getEnergyConsumptionTotalData?id=${id}`)
}
// 用电趋势
export const getEnergyConsumptionDnBarChart = (params): Promise<ApiResponse> => {
    return service.get('screen/energyConsumption/getEnergyConsumptionDnBarChart', {
        params: params
    })
}
// 同比
export const getEnergyAnalogicalAna1lysisChart = (deviceIds: any, endDate: string, startDate: string): Promise<ApiResponse> => {
    return service.get(`screen/energyConsumption/getEnergyAnalogicalAna1lysisChart?deviceIds=${deviceIds}&startDate=${startDate}&endDate=${endDate}`)
}
// 环比
export const getEnergyChainAnalysisChart = (deviceIds: any, date: any): Promise<ApiResponse> => {
    let paramsD = ''
    if (date && date.length) {
        date.forEach((item,index)=>{
            paramsD=`${paramsD}&dateTntervals[${index}].startDate=${item} 00:00:00`
            paramsD=`${paramsD}&dateTntervals[${index}].endDate=${item} 23:59:59`
        })
    }
    return service.get(encodeURI(`screen/energyConsumption/getEnergyChainAnalysisChart?deviceIds=${deviceIds}${paramsD}`))
}
// 统计日期
export const getReportDates = (): Promise<ApiResponse> => {
    return service.get(`screen/energyConsumption/getReportDates`)
}

/**
 * 装置检测
 */
// 统计信息
export const getScreenDeviceMonitorCount = (id: string): Promise<ApiResponse> => {
    return service.get(`screen/deviceMonitor/getScreenDeviceMonitorCount?id=${id}`)
}
// 检测列表
export const getScreenDeviceMonitorList = (id: string, pageNum: number, pageSize: number): Promise<ApiResponse> => {
    return service.get(`screen/deviceMonitor/getScreenDeviceMonitorList?id=${id}&pageNum=${pageNum}&pageSize=${pageSize}`)
}
// 成绩公告
export const getScreenScoreNoticeList = (type: number): Promise<ApiResponse> => {
    return service.get(`screen/deviceMonitor/getScreenScoreNoticeList?type=${type}&pageNum=1&pageSize=100`)
}
// 工具信息
export const getScreenToolInfoList = (): Promise<ApiResponse> => {
    return service.get(`screen/deviceMonitor/getScreenToolInfoList?pageNum=1&pageSize=100`)
}
// 存取记录
export const getScreenDataToolHisList = (type: number): Promise<ApiResponse> => {
    return service.get(`screen/deviceMonitor/getScreenDataToolHisList?type=${type}&pageNum=1&pageSize=100`)
}

// 盘点信息
export const checkDataToolHis = (type: number): Promise<ApiResponse> => {
    return service.get(`screen/deviceMonitor/checkDataToolHis?type=${type}&pageNum=1&pageSize=100`)
}